1 00:00:00,150 --> 00:00:03,010 Now I want to make a chuck spawn or two spawn. 2 00:00:03,030 --> 00:00:05,670 Chuck, If he dies, he's down here fighting zombies. 3 00:00:05,670 --> 00:00:07,110 People might be shooting at him. 4 00:00:07,110 --> 00:00:11,650 We're always going to want to chuck around, so let's grab Chuck. 5 00:00:11,670 --> 00:00:12,810 He's in the workspace. 6 00:00:12,810 --> 00:00:17,100 There's the workspace, there's Chuck, Drag him down to server storage. 7 00:00:17,250 --> 00:00:18,000 Here it is. 8 00:00:18,000 --> 00:00:18,930 Server storage. 9 00:00:18,930 --> 00:00:23,160 I'll just put them on the top level there or first level of server storage. 10 00:00:23,280 --> 00:00:27,630 Now I'm going to go to session utils and write my spawning routine there. 11 00:00:27,630 --> 00:00:30,990 Session utils which is in server script service. 12 00:00:31,350 --> 00:00:32,780 This is the top. 13 00:00:32,790 --> 00:00:35,090 We'll go down there a little bit, maybe under start way. 14 00:00:35,100 --> 00:00:36,390 We didn't do anything with that. 15 00:00:36,840 --> 00:00:38,850 There's a few things we've got to clean up yet. 16 00:00:39,780 --> 00:00:44,640 Let's make a function local function utils. 17 00:00:44,640 --> 00:00:45,540 There we go. 18 00:00:45,540 --> 00:00:49,470 And I'll say spawn and pick and we'll pass. 19 00:00:49,470 --> 00:00:51,420 In the MPC we want to spawn. 20 00:00:51,420 --> 00:00:56,340 This time it's Chuck, but maybe we'll get another NPC like a shopkeeper or something. 21 00:00:56,700 --> 00:01:01,980 All right, so first thing we've got to do, if we're spawning an MPC is check to make sure it's not 22 00:01:01,980 --> 00:01:03,300 already in the world. 23 00:01:03,550 --> 00:01:03,670 Right. 24 00:01:03,720 --> 00:01:12,750 So let's do a local, make a variable for NPC in world and we will check to see if the MPC is in the 25 00:01:12,750 --> 00:01:13,350 world. 26 00:01:13,590 --> 00:01:19,980 All of my MPC is not the monsters, but the MPC are in the workspace, so this isn't going to be a problem. 27 00:01:19,980 --> 00:01:25,080 But we might have to be more sophisticated with our code if we start putting them in folders. 28 00:01:25,410 --> 00:01:25,770 All right. 29 00:01:25,770 --> 00:01:31,170 So I'm going to do a fine first child because he might not be there. 30 00:01:31,170 --> 00:01:35,600 If you wait for child and he's dead, you're going to get hung up here in the code. 31 00:01:35,610 --> 00:01:38,540 So let's look for the MPC. 32 00:01:39,600 --> 00:01:41,220 If he's in the world, fine. 33 00:01:41,610 --> 00:01:54,510 If not MPC in world, then we've got to create a new one, let's call it we'll say local, new and NPC, 34 00:01:55,260 --> 00:01:57,570 and we're going to get them from server storage. 35 00:01:57,570 --> 00:01:57,750 Right? 36 00:01:57,750 --> 00:02:00,030 I got a variable for server storage. 37 00:02:00,030 --> 00:02:03,780 We can do a wait for child here because we know it's in server storage. 38 00:02:03,780 --> 00:02:04,770 We put it there. 39 00:02:05,050 --> 00:02:08,730 I was an NPC and then we'll just clone it. 40 00:02:10,590 --> 00:02:11,400 There we go. 41 00:02:11,550 --> 00:02:14,130 So we did a few things in that in that line. 42 00:02:14,130 --> 00:02:19,140 Now I'll do NPC if I can get my NPC. 43 00:02:20,970 --> 00:02:22,470 Oh new NPC. 44 00:02:22,470 --> 00:02:27,480 Sorry parent will be the workspace. 45 00:02:27,480 --> 00:02:28,290 There we go. 46 00:02:28,290 --> 00:02:33,890 We got our NPC in the workspace but we still have to call us, right? 47 00:02:33,900 --> 00:02:35,010 We haven't called it. 48 00:02:35,340 --> 00:02:36,650 Where do we call? 49 00:02:36,660 --> 00:02:39,300 Let's call it from the wav loop. 50 00:02:40,860 --> 00:02:45,330 You know, there's a wave loop perhaps right under start wave. 51 00:02:46,590 --> 00:02:51,360 Let's do a utils spawn and pick 52 00:02:54,900 --> 00:02:56,070 Chuck. 53 00:02:56,760 --> 00:02:57,840 Oh, my gosh. 54 00:02:57,990 --> 00:03:01,040 Norris, make sure you spell it right. 55 00:03:01,050 --> 00:03:05,820 I know I kind of butchered that, but if we go down here, click on Chuck Norris. 56 00:03:05,820 --> 00:03:06,630 Look at the name. 57 00:03:06,630 --> 00:03:08,280 You might even want to just copy it. 58 00:03:08,280 --> 00:03:10,980 If you're typing is a little bit like mine is today. 59 00:03:10,980 --> 00:03:11,970 Control V. 60 00:03:12,000 --> 00:03:12,750 There we go. 61 00:03:12,750 --> 00:03:14,130 Now we got Chuck Norris. 62 00:03:14,430 --> 00:03:19,290 We're not going to be able to kill him very easily, though, because he's really, really strong. 63 00:03:19,290 --> 00:03:22,250 So let's go to replicated storage. 64 00:03:22,260 --> 00:03:28,230 I have a simple pistol for my character inside the damage on the simple pistol. 65 00:03:28,320 --> 00:03:30,240 Let's crank that up. 66 00:03:30,750 --> 00:03:36,450 Let's crank it up to 100 because Chuck has a health of 400. 67 00:03:36,900 --> 00:03:41,730 But also on Chuck, let's find Chuck again. 68 00:03:43,150 --> 00:03:45,040 Server storage. 69 00:03:45,740 --> 00:03:47,000 Chuck Norris. 70 00:03:47,240 --> 00:03:52,920 I don't know if you noticed, but we don't have the health bar above him with his name tag and everything. 71 00:03:52,940 --> 00:03:55,640 Let's go ahead and change that so we could see his health. 72 00:03:55,670 --> 00:03:57,260 Chuck Norris. 73 00:03:57,530 --> 00:03:59,180 Humanoid. 74 00:03:59,390 --> 00:04:04,370 Look for the display distance type on the humanoid. 75 00:04:04,400 --> 00:04:05,960 We'll set it to viewer. 76 00:04:05,990 --> 00:04:07,940 Now we can see his health. 77 00:04:08,090 --> 00:04:11,720 And we got one more thing to do to Chuck. 78 00:04:11,930 --> 00:04:21,290 Let's open up the move NPC and I want to make sure that when he dies, we clear him from the workspace. 79 00:04:21,290 --> 00:04:21,560 Right? 80 00:04:21,560 --> 00:04:27,550 Because if we find Chuck, even though he's dead, we're not going to spawn a new Chuck. 81 00:04:27,560 --> 00:04:37,190 So I'm going to do I have the humanoid, I have the eye humanoid of Chuck and we'll do a dot die event, 82 00:04:37,850 --> 00:04:41,540 connect that to a function. 83 00:04:42,020 --> 00:04:52,790 And then I'll just say game dot debris, colon, add item I NPC, which is Chuck Norris, and then we'll 84 00:04:52,790 --> 00:04:53,960 say 2 seconds. 85 00:04:53,960 --> 00:05:00,110 So we'll clean the debris up from Chuck 2 seconds after he dies, it'll remove him from the world. 86 00:05:00,110 --> 00:05:02,500 And that way we can spawn a new Chuck. 87 00:05:02,510 --> 00:05:04,100 I think we're good to go. 88 00:05:04,100 --> 00:05:05,330 Let's go ahead. 89 00:05:06,190 --> 00:05:10,870 Open that up, play from here, see what's going on. 90 00:05:10,870 --> 00:05:13,300 So we should see a chuck pretty soon. 91 00:05:15,820 --> 00:05:16,740 Any minute. 92 00:05:17,790 --> 00:05:18,890 There he is. 93 00:05:18,960 --> 00:05:22,500 So he spawns into the world pretty soon. 94 00:05:22,520 --> 00:05:22,710 Ooh. 95 00:05:23,170 --> 00:05:24,180 Get a coin. 96 00:05:25,810 --> 00:05:32,410 I think they changed run animation on my on our characters in the last update. 97 00:05:32,410 --> 00:05:33,370 I'm going to shoot Chuck. 98 00:05:33,850 --> 00:05:36,580 I got to get back up, though, because Chuck's pretty tough. 99 00:05:40,690 --> 00:05:41,080 All right. 100 00:05:41,080 --> 00:05:41,560 Oh, that's right. 101 00:05:41,560 --> 00:05:43,120 We don't have them attacking us yet. 102 00:05:43,120 --> 00:05:45,040 So there's Chuck again. 103 00:05:45,370 --> 00:05:46,120 All right? 104 00:05:46,120 --> 00:05:46,630 That's right. 105 00:05:46,630 --> 00:05:50,650 We got to do we have to make Chuck attack us when we shoot him. 106 00:05:51,070 --> 00:05:52,360 I like that health bar. 107 00:05:52,750 --> 00:05:57,580 Oh, let's add health to health regeneration to Chuck. 108 00:05:57,790 --> 00:05:59,320 This is how we do that. 109 00:05:59,350 --> 00:06:00,960 This is an easy way. 110 00:06:00,970 --> 00:06:04,450 We're going to open up the workspace while we're playing. 111 00:06:04,960 --> 00:06:12,400 We're going to find our character Semtech Nitro one and then get that health script. 112 00:06:12,400 --> 00:06:14,050 This is the health region. 113 00:06:14,050 --> 00:06:18,370 Click on it, right click, and then I'll do a copy. 114 00:06:19,180 --> 00:06:23,350 You have to turn the game off or it won't save when you go to paste it. 115 00:06:23,920 --> 00:06:24,250 All right. 116 00:06:24,250 --> 00:06:25,790 Now we're going to look for Chuck Norris. 117 00:06:25,810 --> 00:06:28,540 Luckily, I have them right here under server storage. 118 00:06:29,520 --> 00:06:32,910 And I'm going to paste into now. 119 00:06:32,910 --> 00:06:35,130 He's going to have health regeneration. 120 00:06:35,160 --> 00:06:36,450 It's actually a simple script. 121 00:06:36,450 --> 00:06:40,820 We could have wrote it ourself, but it's going to regenerate his health just like a player. 122 00:06:40,830 --> 00:06:42,780 So he's getting more and more player like. 123 00:06:44,870 --> 00:06:53,570 So the next video will add dynamic tagging so that people can become enemies if they hurt Chuck.